function addLoadEvent(func)
{
	var oldonload = window.onload;

    if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

/* Drop Down Menu (IE Fix) */
sfHover = function()
{	
	var elements = $ES('li', 'nav');

	for (var i=0; i<elements.length; i++)
	{
		var element = elements[i];
		element.addEvent('mouseover', function(){ this.addClass('hover'); });
		element.addEvent('mouseout', function(){ this.removeClass('hover'); });
	}	
}

/* Accordion */
var accordion;
var accordionClicks;
var accordionContents;

wAccordion = function()
{
    
var Tips1 = new Tips($$('.Tips1'), {
	showDelay: 600,
});
  
    
	accordionClicks   = document.getElementsByClassName('accordion-click');
	accordionContents = document.getElementsByClassName('accordion-content');
	accordion = new Accordion(accordionClicks, accordionContents, {
							      onActive:     function(toggler, element){
													toggler.addClass('active');
													element.setStyle('border', 'solid 1px #999999');
													element.setStyle('border-top', 'none');
												},
								  onBackground: function(toggler, element){
													toggler.removeClass('active');
												}											
							  });
}

		function ajaxfilemanager(field_name, url, type, win) {
			var ajaxfilemanagerurl = "../../../../JS/TinyMCE/plugins/ajaxfilemanager/ajaxfilemanager.php";
			switch (type) {
				case "image":
					ajaxfilemanagerurl += "?type=img";
					break;
				case "media":
					ajaxfilemanagerurl += "?type=media";
					break;
				case "flash": //for older versions of tinymce
					ajaxfilemanagerurl += "?type=media";
					break;
				case "file":
					ajaxfilemanagerurl += "?type=files";
					break;
				default:
					return false;
			}
			var fileBrowserWindow = new Array();
			fileBrowserWindow["file"] = ajaxfilemanagerurl;
			fileBrowserWindow["title"] = "Ajax File Manager";
			fileBrowserWindow["width"] = "782";
			fileBrowserWindow["height"] = "440";
			fileBrowserWindow["close_previous"] = "no";
			tinyMCE.openWindow(fileBrowserWindow, {
			  window : win,
			  input : field_name,
			  resizable : "yes",
			  inline : "yes",
			  editor_id : tinyMCE.getWindowArg("editor_id")
			});
			
			return false;
			//window.open(connector, "ajaxfilemanager", "modal,width=766,height=340,resizable");
		}
addLoadEvent(wAccordion);
addLoadEvent(sfHover);

	function fileBrowserCallBack(field_name, url, type, win) {
		var connector = "../../filemanager/browser.html?Connector=connectors/php/connector.php";
		var enableAutoTypeSelection = true;
		
		var cType;
		tinymcpuk_field = field_name;
		tinymcpuk = win;
		
		switch (type) {
			case "image":
				cType = "Image";
				break;
			case "flash":
				cType = "Flash";
				break;
			case "file":
				cType = "File";
				break;
		}
		
		if (enableAutoTypeSelection && cType) {
			connector += "&Type=" + cType;
		}
		
		window.open(connector, "tinymcpuk", "modal,width=600,height=400");
	}

